import numpy as np
import cv2

# 相机内参矩阵
K = np.array([[501.11272909, 0., 321.4141358],
              [0., 586.67063738, 216.57703686],
              [0., 0., 1.]])

# 畸变系数
dist_coeffs = np.array([7.86783352e-02, -2.60488060e-01, 3.40528618e-04, -5.95622203e-04, 4.57489513e-01])

# 图像坐标系中的坐标
image_points = np.array([[100, 200], [300, 400], [500, 600]], dtype=np.float32)

# 将图像坐标系中的坐标转换为相机坐标系中的坐标
camera_points = cv2.undistortPoints(image_points.reshape(-1, 1, 2), K, dist_coeffs)
camera_points = camera_points.reshape(-1, 2)

# 打印转换后的结果
print("图像坐标系（像素）：", image_points)
print("相机坐标系（毫米）：", camera_points)